package sourceagile.server.subversionFileRepository;

import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.auth.BasicAuthenticationManager;
import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;

/**
 * Open a connection with the repository that was entered in the project data.
 * 
 * @Architecture
 */
public class SubversionRepositoryConnection {

	public static SVNRepository connect(String URI, String username,
			String password) throws SVNException {

		DAVRepositoryFactory.setup();

		SVNRepository repository = SVNRepositoryFactory.create(SVNURL
				.parseURIDecoded(URI));

		repository.setAuthenticationManager(new BasicAuthenticationManager(
				username, password));

		return repository;
	}

}
